/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Responsive height for full browser */
@media (min-height: 600px) {
    body:not(.iframe-mode) .container {
        height: 90vh;
    }
}

/* Control Panel - Left side */
.control-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    min-width: 200px;
}

/* Slider Groups */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-label {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 5px;
}

.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4a90e2;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.5);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4a90e2;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.slider-marks {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* BMI Output */
.bmi-output {
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.bmi-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.bmi-category {
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* BMI Category Colors */
.bmi-output.underweight {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1976d2;
}

.bmi-output.healthy {
    background: #e8f5e8;
    border-color: #4caf50;
    color: #2e7d32;
}

.bmi-output.overweight {
    background: #fff3e0;
    border-color: #ff9800;
    color: #f57c00;
}

.bmi-output.obese {
    background: #ffebee;
    border-color: #f44336;
    color: #d32f2f;
}

/* Formula Display */
.formula-display {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-align: center;
    border: 1px solid #dee2e6;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: #4a90e2;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Touch-friendly size */
}

.action-btn:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.action-btn:active {
    transform: translateY(0);
}

/* Human Figure Container */
.figure-container {
    flex: 1.5;
    display: flex;
    justify-content: center;
    align-items: stretch;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 6px;
    overflow: hidden;
}

.human-svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    display: block;
    transition: all 0.3s ease;
}

/* Reference Panel - Right side */
.reference-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    min-width: 180px;
}

.reference-title {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
    cursor: help;
}

.bmi-categories {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.category-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.category-text {
    font-size: 13px;
    line-height: 1.3;
}

/* Category Colors */
.underweight .category-color { background: #2196f3; }
.healthy .category-color { background: #4caf50; }
.overweight .category-color { background: #ff9800; }
.obese .category-color { background: #f44336; }

.explanation {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    border-left: 4px solid #4a90e2;
}

.explanation p {
    cursor: help;
}

/* Questions Panel */
.questions-panel {
    background: #e8f4fd;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #4a90e2;
}

.question-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #2c3e50;
}

.question-list {
    list-style: none;
    font-size: 13px;
    line-height: 1.4;
}

.question-list li {
    margin-bottom: 6px;
    padding-left: 15px;
    position: relative;
}

.question-list li:before {
    content: "?";
    position: absolute;
    left: 0;
    color: #4a90e2;
    font-weight: bold;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 12px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        height: auto;
        min-height: 450px;
    }
    
    .control-panel,
    .reference-panel {
        flex: none;
        min-width: auto;
    }
    
    .figure-container {
        order: -1;
        flex: none;
        height: 200px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
    }
    
    .slider-label {
        font-size: 14px;
    }
    
    .bmi-value {
        font-size: 20px;
    }
}

/* ===== LEARNING BANNER ===== */
.learning-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 16px;
    font-size: 13px;
}

.close-banner {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    flex-shrink: 0;
}
.close-banner:hover { opacity: 1; }

/* ===== DID YOU KNOW ===== */
.did-you-know {
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    line-height: 1.4;
    font-style: italic;
    animation: fadeInFact 0.4s ease;
}
@keyframes fadeInFact {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.did-you-know.healthy-fact    { background: #e8f5e9; color: #2e7d32; border-left: 3px solid #4caf50; }
.did-you-know.underweight-fact{ background: #e3f2fd; color: #1565c0; border-left: 3px solid #2196f3; }
.did-you-know.overweight-fact { background: #fff3e0; color: #e65100; border-left: 3px solid #ff9800; }
.did-you-know.obese-fact      { background: #ffebee; color: #c62828; border-left: 3px solid #f44336; }

/* ===== SUCCESS BADGE ===== */
.success-badge {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #2e7d32;
    padding: 0;
    border-radius: 6px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease, padding 0.3s ease;
}
.success-badge.show {
    opacity: 1;
    max-height: 40px;
    padding: 6px;
    background: #e8f5e9;
}

/* ===== FORMULA DISPLAY — 2-line colour-coded ===== */
.formula-step    { display: block; line-height: 1.8; }
.formula-mass    { color: #1565c0; font-weight: 700; }
.formula-height  { color: #2e7d32; font-weight: 700; }
.formula-result  { font-weight: 700; }
.formula-result.underweight { color: #1976d2; }
.formula-result.healthy     { color: #2e7d32; }
.formula-result.overweight  { color: #f57c00; }
.formula-result.obese       { color: #d32f2f; }

/* ===== PRESET BUTTONS ===== */
.preset-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.preset-label {
    font-size: 11px;
    color: #777;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.preset-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.preset-btn {
    flex: 1;
    padding: 5px 6px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 30px;
    color: white;
}
.preset-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.preset-underweight { background: #2196f3; }
.preset-healthy     { background: #4caf50; }
.preset-overweight  { background: #ff9800; }
.preset-obese       { background: #f44336; }

/* ===== EXPLORE Q&A REVEAL ===== */
.reveal-btn {
    background: none;
    border: 1px solid #4a90e2;
    color: #4a90e2;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 4px;
    white-space: nowrap;
    transition: all 0.2s;
    vertical-align: middle;
}
.reveal-btn:hover        { background: #4a90e2; color: white; }
.reveal-btn.revealed     { background: #e8f4fd; color: #2c6fad; border-color: #2c6fad; }
.explore-answer {
    margin-top: 5px;
    padding: 6px 10px;
    background: #f0fdf4;
    border-left: 3px solid #4caf50;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: #2c3e50;
    line-height: 1.4;
    animation: slideDown 0.2s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== ENHANCED HINTS MODAL ===== */
.modal-content { animation: modalFadeIn 0.25s ease; }
@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}
#hints-list li { margin-bottom: 10px; line-height: 1.5; }
.close-hints-btn {
    display: block;
    margin: 16px auto 0;
    padding: 10px 28px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.close-hints-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ===== PANEL HEADER & TABS ===== */
.panel-header {
    display: flex;
    align-items: center;
    gap: 6px;
}
.panel-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}
.panel-tab {
    flex: 1;
    padding: 5px 4px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    background: #f5f5f5;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #555;
    white-space: nowrap;
}
.panel-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
}
.panel-tab:hover:not(.active) { background: #ebebeb; }
.tab-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.tab-content[hidden] { display: none !important; }

/* ===== ANALYTICS BUTTON ===== */
.analytics-btn {
    background: none;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    transition: all 0.2s;
    flex-shrink: 0;
    line-height: 1;
}
.analytics-btn:hover { background: #e8f4fd; border-color: #4a90e2; }

/* ===== QUIZ STYLES ===== */
.quiz-score-bar {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    background: #e8f4fd;
    border-radius: 6px;
    padding: 5px 8px;
}
#quiz-score { color: #4a90e2; font-size: 17px; }

.quiz-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 9px;
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.quiz-question { font-size: 12px; line-height: 1.4; color: #2c3e50; }
.quiz-svg-wrap {
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #eee;
}
.quiz-options {
    display: flex;
    gap: 6px;
}
.quiz-opt {
    flex: 1;
    padding: 7px 4px;
    border: 1.5px solid #4a90e2;
    border-radius: 6px;
    background: white;
    color: #2c3e50;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.quiz-opt:hover:not(:disabled) { background: #e8f4fd; }
.quiz-opt:disabled { cursor: default; opacity: 0.85; }
.quiz-opt.correct { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.quiz-opt.wrong   { background: #ffebee; border-color: #f44336; color: #c62828; }

.quiz-feedback {
    font-size: 11.5px;
    line-height: 1.4;
    padding: 6px 8px;
    border-radius: 6px;
    animation: slideDown 0.2s ease;
}
.quiz-feedback.correct { background: #e8f5e9; color: #2e7d32; border-left: 3px solid #4caf50; }
.quiz-feedback.wrong   { background: #ffebee; color: #c62828; border-left: 3px solid #f44336; }

.quiz-bmi-live {
    text-align: center;
    font-size: 13px;
    color: #555;
    font-weight: 500;
    padding: 4px 0;
}
.quiz-bmi-value {
    font-size: 20px;
    font-weight: 700;
    color: #4a90e2;
    transition: color 0.3s;
}
.quiz-bmi-value.healthy    { color: #2e7d32; }
.quiz-bmi-value.underweight{ color: #1565c0; }
.quiz-bmi-value.overweight { color: #e65100; }
.quiz-bmi-value.obese      { color: #c62828; }

.quiz-submit-btn {
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.quiz-submit-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.quiz-submit-btn:disabled { opacity: 0.6; cursor: default; }

.quiz-reset-btn {
    background: none;
    border: 1.5px solid #bbb;
    border-radius: 6px;
    color: #777;
    font-size: 11px;
    padding: 5px 12px;
    cursor: pointer;
    align-self: center;
    transition: all 0.2s;
}
.quiz-reset-btn:hover { background: #f0f0f0; color: #333; border-color: #999; }

/* ===== ANALYTICS MODAL ===== */
.analytics-modal-content { max-width: 460px; }
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 12px;
}
.analytics-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
    border: 1px solid #e9ecef;
}
.analytics-card .a-label { font-size: 11px; color: #777; margin-bottom: 3px; }
.analytics-card .a-value { font-size: 22px; font-weight: 700; color: #2c3e50; }
.analytics-quiz-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    background: #f8f9fa;
    font-size: 12.5px;
    margin-bottom: 4px;
}
.analytics-cat-pills {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.a-pill {
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    
    .action-btn {
        min-height: 48px;
        font-size: 16px;
    }
    
    .category-item {
        padding: 12px 8px;
    }
}